package com.huilian.iotbox.admin.wap.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.huilian.iotbox.admin.wap.dao.FeedbackDao;
import com.huilian.iotbox.admin.wap.service.*;
import com.huilian.iotbox.data.common.ServerResponse;
import com.huilian.iotbox.data.dto.*;
import com.huilian.iotbox.data.vo.FeedbackVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author 龙 路 飞
 * @CreateDate: 2021-10-15 17:34
 * @Description:
 */
@Slf4j
@Service
public class FeedbackServiceImpl implements FeedbackService {
    @Resource
    private FeedbackDao feedbackDao;
    @Override
    public PageInfo findList(FeedbackDto feedbackDto) {
        PageHelper.startPage(feedbackDto.getPageNum(), feedbackDto.getPageSize(), " fb.createTime desc");
        List<FeedbackVo> list = feedbackDao.findList(feedbackDto);
        PageInfo pageInfo = new PageInfo(list);
        return pageInfo;
    }

    @Override
    public FeedbackVo findByIdAndUserId(FeedbackDto feedbackDto) {
        return feedbackDao.findByIdAndUserId(feedbackDto);
    }

    @Override
    public ServerResponse update(FeedbackDto feedbackDto) {
        feedbackDto.setStatus(1);
        return ServerResponse.createBySuccess(feedbackDao.update(feedbackDto));
    }

}
